package customer;

import java.sql.PreparedStatement;

import com.opensymphony.xwork2.ActionSupport;

import connection.MyConnection;

public class CustomerEdit extends ActionSupport {

	public int id;
	public String name;
	public String product;
	public String phone;
	public double totalpayment;
	public double paidpayment;
	public double remainpayment;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getProduct() {
		return product;
	}
	public void setProduct(String product) {
		this.product = product;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public double getTotalpayment() {
		return totalpayment;
	}
	public void setTotalpayment(double totalpayment) {
		this.totalpayment = totalpayment;
	}
	public double getPaidpayment() {
		return paidpayment;
	}
	public void setPaidpayment(double paidpayment) {
		this.paidpayment = paidpayment;
	}
	public double getRemainpayment() {
		return remainpayment;
	}
	public void setRemainpayment(double remainpayment) {
		this.remainpayment = remainpayment;
	}
	
	@Override
	
	public String execute() throws Exception
	{
		
		MyConnection mc = new MyConnection();
		mc.connect();
		
		try
		{
			PreparedStatement ps = mc.con.prepareStatement("update customer set name=?, product=? where id = '"+id+"' ");
			ps.setString(1, name);
			ps.setString(2, product);
			//ps.setString(2, phone);			

			//ps.setDouble(4, totalpayment);
			//ps.setDouble(5, paidpayment);
			//ps.setDouble(6, remainpayment);
			//ps.setString(6, product);
			ps.executeUpdate();
			
			
		}
		
		catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return "success";
	}
	
}
